<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_2105614_bh68n5vv0og.css">
    <title>Document</title>
    <style>
        .box{
            position: relative;
            width: 400px;
            border-bottom: 1px solid #ccc;
            margin: 100px auto;
        }
        label{
            position: absolute;
            top: 5px;
            right: 3px;
        }
        .box input{
            width: 370px;
            height: 30px;
            border: 0;
            outline: none;
        }
    </style>
</head>
<body>
    <div class="box">
        <label for="">
            <img class="iconfont icon-biyan" src="" alt="" id="eye">
        </label>
        <input type="password" name="" id="pwd">
    </div>
    <script>
        var eye = document.querySelector('#eye');
        var pwd = document.querySelector('#pwd');
        var flag = 0;
        eye.onclick = function(){
            if(flag == 0){
                pwd.type = 'text';
                eye.className = 'iconfont icon-weixiao';
                flag = 1;
            }else{
                pwd.type = 'password';
                eye.className = 'iconfont icon-biyan';
                flag = 0;
            }
        }
    </script>
</body>
</html>